package IC.Parser;

import java_cup.runtime.Symbol;

public class Token extends Symbol {
    
	private int line;
	private int id;
	private Object value;
	
	public Token(int id, int line) {
        super(id, ++line, 0);
        this.line = line;
        this.id = id;
    }
	
	public Token(int id, int line, Object value) {
		super(id, ++line, 0, value);
		this.value = value;
		this.id = id;
		this.line = line;
	}

	// ================== getters =======================

	public int getLine() {
		return line;
	}

	public int getId() {
		return id;
	}

	public Object getValue() {
		return value;
	}
	
	// ==========================================
	/**
	 * @return true if id is one of the following : number, identifier, class identifier or quoted string
	 */
	public boolean isValueNeeded(){
		return (id == IC.Parser.sym.INTEGER) || (id == IC.Parser.sym.ID) || (id == IC.Parser.sym.CLASS_ID) || (id == IC.Parser.sym.QUOTE);
	}
}
